<template>
  <div class="container">
    <el-collapse v-model="activeNames">
      <el-collapse-item title="任务信息" name="1">
        <el-form :model="settlementData" class="grid-flex" label-width="120px">
          <template v-for="key in settlementKeys">
            <el-form-item
              :key="key"
              :label="$language.local(key)"
              v-if="/WorkContent|RecruitmentRequirements/.test(key)"
              class="textarea"
            >
              <xy-input
                disabled
                v-model="settlementData[key]"
                type="textarea"
              ></xy-input>
            </el-form-item>
            <el-form-item
              v-else-if="key === 'SID'"
              :key="key"
              :label="$language.local(key)"
            >
              <select-service v-model="settlementData[key]"></select-service>
            </el-form-item>
            <el-form-item
              v-else-if="key === 'MID'"
              :key="key"
              :label="$language.local(key)"
            >
              <select-merchantid
                disabled
                v-model="settlementData[key]"
              ></select-merchantid>
            </el-form-item>
            <el-form-item
              v-else-if="key === 'SettlementModes'"
              :key="key"
              :label="$language.local(key)"
              class="textarea"
            >
              <xy-input disabled v-model="settlementData[key]"></xy-input>
            </el-form-item>
            <el-form-item
              v-else-if="key === 'Amount'"
              :key="key"
              :label="$language.local(key)"
            >
              <xy-input v-model="settlementData[key]"></xy-input>
            </el-form-item>
            <el-form-item v-else :key="key" :label="$language.local(key)">
              <xy-input disabled v-model="settlementData[key]"></xy-input>
            </el-form-item>
          </template>
        </el-form>
      </el-collapse-item>
      <el-collapse-item title="自由职业者列表" name="2">
        <xy-table
          :api="empApi"
          :columns="employeesColumns"
          :param="empTableParam"
          class="settlement-table"
        >
          <template #addItem=""><span></span></template>
          <template #operationButton=""><span></span></template>
        </xy-table>
      </el-collapse-item>
    </el-collapse>
    <div class="symbol"></div>
    <div class="form-footer pt-2 pb-2">
      <el-button @click="$router.go(-1)" icon="el-icon-back">返 回</el-button>
      <div class="total-amount ml-2 mr-2">
        本次结算金额: ￥<span class="red amount-num"> {{ 1110.0 }}</span> 元
      </div>
      <el-button type="danger" icon="el-icon-finished">结算</el-button>
      <div class="total-amount ml-2 mr-2">
        可结算余额: ￥<span class="red amount-num"> {{ 0.0 }}</span> 元
      </div>
    </div>
  </div>
</template>

<script>
import API from "../../plugins/api";
export default {
  data() {
    return {
      activeNames: ["1", "2"],
      settlementData: {},
      settlementKeys: {
        BusinessNo: "string",
        atime: "2021-06-29T13:36:55.763Z",
        SPID: 0,
        MID: 0,
        MerchantName: "string",
        SPName: "string",
        // SettlementDate: "2021-06-29T13:36:55.763Z",
        TSKSettlementType: "string",
        AttFile: "string",
        otherFile: "string",
        Amount: 0,
        Status: 0,
        paystatus: 0,
      },

      empApi: new API("/api/employee/GetList"),
      empTableParam: {
        auditStatus: 1,
      },
      employeesColumns: {
        EmpName: "梁由之",
        IdCardNo: "510724198510242428",
        BankCardNo: "6228460480014077810",
        // BankCardNos: "6228460480014077810",
        // EmpPhones: "13678289922",
        EmpPhone: "13678289922",
      },
      employees: [],
    };
  },
  created() {
    this.getTask();
    // this.getEemloyee();
  },
  methods: {
    async getTask() {
      const { id } = this.$route.query;
      const response = await this.$http.get(
        `/api/ServiceProject/GetModel/${id}`
      );
      console.log(response);
      this.settlementData = response.data.Data;
    },
    async getEemloyee() {
      const response = await this.$http.get(
        "/api/employee/GetList?auditStatus=1"
      );
      console.log(response);
      this.employees = response.data.Data;
    },
    settlementTask(row) {
      console.log(row);
    },
  },
};
</script>

<style lang="less" scoped>
.container {
  // position: relative;
  .form-footer {
    z-index: 100;
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    align-items: center;
    background-color: white;
    .amount-num {
      font-size: 1.5rem;
    }
  }
}

.settlement-table {
  height: 200;
  min-height: 300px;
  position: relative;
  padding-bottom: 5rem;
}
.symbol {
  height: 5rem;
}
</style>
